package cedar.sentinel.GWT.client;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.net.Socket;
import java.net.UnknownHostException;

public class TCPClient {
	String toServer;

	Socket clientSocket;

	BufferedReader inFromUser;

	PrintWriter outToServer;

	public TCPClient(String addr, int port) throws UnknownHostException,
			IOException {
		clientSocket = new Socket(addr, port);
		inFromUser = new BufferedReader(new InputStreamReader(System.in));
		outToServer = new PrintWriter(clientSocket.getOutputStream(), true);
	}

	public void sendToServer(int command) throws IOException {
		toServer = "" + command;
		outToServer.println(toServer);
	}

	public void toggleState() {
		toServer = "s";
		outToServer.println(toServer);
	}
	public void quit() {
		toServer = "q";
		outToServer.println(toServer);
	}
}